﻿using System;
using System.Collections;
using System.Collections.Generic;

using Wsitech.Model;
using Wsitech.Persistence.Interface;

namespace Wsitech.Persistence.Dao
{
    /// <summary>
    /// 功能：     Keyword业务接口的实现
    /// 作者：     LI
    /// 日期：     5/16/2012
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class KeywordSqlMapDao : BaseSqlMapDao, IKeywordDao
    {
        private KeywordSqlMapDao()
        {
            //
            // TODO: 此处添加KeywordSqlMapDao的构造函数
            //
        }

        #region 懒汉单例模式

        private static KeywordSqlMapDao instance = null;
        private static object syncRoot = new object();
        public static IKeywordDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new KeywordSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        #endregion

        #region	基本功能 ，不可修改

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="KeyId"></param>
        /// <returns></returns>
        public Keyword GetDetail(System.String keyid)
        {
            try
            {
                return ExecuteQueryForObject<Keyword>("SelectKeyword", keyid) as Keyword;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<Keyword> GetList()
        {
            try
            {
                return ExecuteQueryForList<Keyword>("SelectKeyword", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<Keyword> GetListByParams(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<Keyword>("SelectKeywordByParams", objParameters);
            }
            catch
            {
                throw;
            }
        }



        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public object Add(Keyword keyword)
        {
            //int id = GetId("Keyword");
            //keyword.KeyId = id;

            try
            {
                return ExecuteInsert("InsertKeyword", keyword);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public int Update(Keyword keyword)
        {
            try
            {
                return ExecuteUpdate("UpdateKeyword", keyword);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="KeyId"></param>
        /// <returns></returns>
        public int Delete(System.String keyid)
        {
            try
            {
                return ExecuteDelete("DeleteKeyword", keyid);
            }
            catch
            {
                throw;
            }
        }
        #endregion

        #region 扩展功能

        #endregion

        public IList<Keyword> GetListByByTextInfoId(string textinfoid)
        {
            return ExecuteQueryForList<Keyword>("GetListByByTextInfoId", textinfoid);
        }
    }
}
